<!-- 搜索表单 -->
<template>
    <el-card shadow="never" >
      <el-form
        label-width="77px"
        class="ele-form-search"
        @keyup.enter.native="search"
        @submit.native.prevent
      >
        <el-row :gutter="15">
          <el-col :lg="6" :md="12">
            <el-form-item label="关键字:">
              <el-input clearable v-model="where.keyword" placeholder="支持标题模糊查询" />
            </el-form-item>
          </el-col>
         
          <el-col :lg="6" :md="12">
            <div class="ele-form-actions">
              <el-button
                type="primary"
                icon="el-icon-search"
                class="ele-btn-icon"
                @click="search"
              >
                查询
              </el-button>
              <el-button @click="reset">重置</el-button>
            </div>
          </el-col>
        </el-row>
      </el-form>
    </el-card>
    </template>
    
    <script>
      const DEFAULT_WHERE = {
        keyword: ''  //关键字
      };
      export default {
        name: 'MediaSearch',
       
        data() {
          return {

            // 表单数据
            where: { ...DEFAULT_WHERE },
          };
        },
        //初始化数据
        created(){
         
        },
    
        methods: {
    
          /* 搜索 */
          search() {
            let params = {
              pageindex: 1,
              conditions: [],
              orderBys: [{ sort: "createDate", order: 1, }],
            };
    
            //关键字查询
            if(this.where.keyword){
              params.conditions.push({
                key:"title",
                operator: 1,
                value: this.where.keyword,
              });
            }
    
            
    
            this.$emit('search', params);
          },
          /*  重置 */
          reset() {
            this.where = { ...DEFAULT_WHERE };
            
            this.search();
          }
        }
      };
    </script>
    